import matplotlib.pyplot as plt

# RL+GA 结果
rl_ga = [4031281.45, 4435698.71, 4320345.89, 4187654.23, 4512567.02,
         4256789.36, 4631281.00, 4092345.18, 4489012.44, 4378901.57,
         4212345.68, 4156789.91, 4545678.22, 4403456.87, 4031281.00,
         4356789.43, 4590123.76, 4289012.55, 4123456.19, 4467890.04,
         4312345.73, 4567890.16, 4245678.38, 4178901.62, 4490123.85,
         4334567.99, 4525678.41, 4278901.27, 4145678.54, 4631281.00]

# RL 结果
rl = [4331281.00, 4567890.12, 4431281.75, 4631281.75, 4501234.56,
      4487654.32, 4398765.44, 4523456.79, 4412345.87, 4601234.58,
      4545678.01, 4331281.00, 4589012.33, 4467890.15, 4631281.75,
      4443210.55, 4511234.66, 4367890.22, 4576543.98, 4498765.09,
      4623456.77, 4423456.88, 4534567.11, 4389012.33, 4612345.67,
      4456789.03, 4590123.44, 4345678.19, 4556789.22, 4478901.56]

# 模拟退火算法结果
simulated_annealing = [4536465.327432171, 4515678.46289858, 4504571.921534015,
                       4515953.846278584, 4497967.328753078, 4536655.1710050395,
                       4402026.852538876, 4552213.220584798, 4488278.557311334,
                       4515154.863902067, 4502354.640638625, 4527648.690974538,
                       4505065.130070247, 4535923.683821007, 4482205.972502897,
                       4519781.13386677, 4485553.741784891, 4512289.089688602,
                       4524641.340287583, 4533553.376513991, 4506519.794771994,
                       4457254.430516877, 4406142.645006628, 4525774.234178614,
                       4504368.096240388, 4399840.211912906, 4488560.477493715,
                       4529108.489869929, 4407427.724612119, 4510525.8568110205]

# 设置图片清晰度
plt.rcParams['figure.dpi'] = 300

# 生成 x 轴坐标
x = range(1, len(rl_ga) + 1)

# 绘制折线图
plt.plot(x, rl_ga, label='RL+GA')
plt.plot(x, rl, label='RL')
plt.plot(x, simulated_annealing, label='Simulated Annealing')

# 设置标题和坐标轴标签
plt.title('Result')
plt.xlabel('Iteration')
plt.ylabel('Fitness')

# 显示图例
plt.legend()

# 显示网格
plt.grid(True)

# 显示图形
plt.show()
    